unit f_r_zrl;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, dxtree, dxdbtree, uni,
  Vcl.StdCtrls, Vcl.Buttons,
  cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters,
  cxCustomData, cxStyles, cxTL, cxMaskEdit, cxTLdxBarBuiltInMenu, cxFilter,
  cxData, cxDataStorage, cxEdit, Data.DB, cxDBData, cxGridLevel,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxClasses,
  cxGridCustomView, cxGrid, cxInplaceContainer, cxDBTL,
  cxTLData, dxBar, frxClass, frxDBSet, MemDS, DBAccess;

// uses
{ Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, dxtree, dxdbtree, uni,
  Vcl.StdCtrls, Vcl.Buttons, cxGraphics, cxControls, cxLookAndFeels,
  cxLookAndFeelPainters, cxCustomData, cxStyles, cxTL, cxMaskEdit,
  cxTLdxBarBuiltInMenu, dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinBlueprint,
  dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide,
  dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
  dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
  dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins,
  dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
  dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
  dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinPumpkin, dxSkinSeven,
  dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver,
  dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld,
  dxSkinsDefaultPainters, dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint,
  dxSkinXmas2008Blue, cxInplaceContainer, cxDBTL, cxTLData, dxSkinscxPCPainter,
  cxFilter, cxData, cxDataStorage, cxEdit, Data.DB, cxDBData,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridLevel,
  cxClasses, cxGridCustomView, cxGrid;
}
type
  TForm2 = class(TForm)
    tl1: TcxDBTreeList;
    cxDBTreeList1name_desc: TcxDBTreeListColumn;
    cxDBTreeList1year: TcxDBTreeListColumn;
    cxGrid1DBTableView1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    cxGrid1DBTableView1godmesr: TcxGridDBColumn;
    cxGrid1DBTableView1godmesn: TcxGridDBColumn;
    cxGrid1DBTableView1tab_no: TcxGridDBColumn;
    cxGrid1DBTableView1knuz: TcxGridDBColumn;
    cxGrid1DBTableView1cf: TcxGridDBColumn;
    cxGrid1DBTableView1df: TcxGridDBColumn;
    cxGrid1DBTableView1summa_n: TcxGridDBColumn;
    cxGrid1DBTableView1summa_u: TcxGridDBColumn;
    dxBarManager1: TdxBarManager;
    dxBarManager1Bar1: TdxBar;
    dxBarButton1: TdxBarButton;
    dxBarButton2: TdxBarButton;
    dxBarButton3: TdxBarButton;
    ds_zrl_rep: TfrxDBDataset;
    zrl_rep: TfrxReport;
    ds_z: TUniDataSource;
    q_z: TUniQuery;
    dxbrbtn1: TdxBarButton;
    rozrah_list: TfrxReport;
    dxbrbtn2: TdxBarButton;
    dxBarSubItem1: TdxBarSubItem;
    dxbrlstm1: TdxBarListItem;
    dxbrsbtm1: TdxBarSubItem;
    dxbrbtn3: TdxBarButton;
    dxbrsbtm2: TdxBarSubItem;
    dxbrbtn4: TdxBarButton;
    narah: TfrxReport;
    ds_narah: TfrxDBDataset;
    q_nar: TUniQuery;
    ds_nar: TUniDataSource;
    ds_nar_z: TUniDataSource;
    q_nar_z: TUniQuery;
    ds_narah_z: TfrxDBDataset;
    ds_aym: TfrxDBDataset;
    narah_z: TfrxReport;
    dxBarSubItem2: TdxBarSubItem;
    dxbrbtn5: TdxBarButton;
    q_nar_ztab_no: TWideStringField;
    q_nar_zcolumn: TWideMemoField;
    q_nar_zsalary: TFloatField;
    q_nar_zdp: TWideStringField;
    q_nar_zcp: TWideStringField;
    q_nar_zdf: TWideStringField;
    q_nar_zcf: TWideStringField;
    q_nar_zintensiv: TFloatField;
    q_nar_znight: TFloatField;
    q_nar_ztualet: TFloatField;
    q_nar_zesv: TFloatField;
    q_nar_zpp: TFloatField;
    q_nar_zsumma_n: TFloatField;
    q_nar_zsumma_u: TFloatField;
    q_nar_zdovyplaty: TFloatField;
    procedure TV1Change(Sender: TObject; Node: TTreeNode);
    procedure tl1FocusedNodeChanged(Sender: TcxCustomTreeList;
      APrevFocusedNode, AFocusedNode: TcxTreeListNode);
    procedure FormShow(Sender: TObject);
    procedure dxBarButton1Click(Sender: TObject);
    procedure dxBarButton3Click(Sender: TObject);

    procedure rozrah_listGetValue(const VarName: string; var Value: Variant);
    procedure dxBarButton2Click(Sender: TObject);
    procedure dxbrbtn3Click(Sender: TObject);
    procedure dxbrbtn5Click(Sender: TObject);
    procedure dxbrbtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

uses
  datam;
{$R *.dfm}

procedure TForm2.dxBarButton1Click(Sender: TObject);
begin
  dm.proc_payroll_total.ParamByName('aym').Value :=
    dm.q_aym.FieldByName('a_ym').Value;
  dm.proc_payroll_total.Execute;
end;

procedure TForm2.dxBarButton2Click(Sender: TObject);
begin
  rozrah_list.ShowReport();
end;

procedure TForm2.dxBarButton3Click(Sender: TObject);
begin
  q_z.Refresh;
  zrl_rep.ShowReport(true);
end;

procedure TForm2.dxbrbtn1Click(Sender: TObject);
begin
dm.proc_payroll_monthly.ParamByName('aym').value:=
    dm.q_aym.FieldByName('a_ym').Value;
  dm.proc_payroll_monthly.Execute;

end;

procedure TForm2.dxbrbtn3Click(Sender: TObject);
begin
  // q_nar.Active:=False;
  // q_nar.ParamByName('aym').Value:=dm.q_aym.FieldByName('a_ym').Value;
  // q_nar.Open;
  q_nar.Refresh;
  narah.ShowReport(true);
end;

procedure TForm2.dxbrbtn5Click(Sender: TObject);
begin
  q_nar_z.Refresh;
  narah_z.ShowReport(true);
end;

procedure TForm2.FormShow(Sender: TObject);
begin

  // ShowMessage('FormShow');

  dm.q_ym_nod.Refresh;
  dm.q_zrl.Refresh;
end;

procedure TForm2.rozrah_listGetValue(const VarName: string; var Value: Variant);
var
  mec: string;

begin
  if VarName = 'godm' then
    Value := dm.q_aym.FieldByName('a_ym').AsString;
  if VarName = 'mes' then
    Value := dm.q_aym.FieldByName('aym').AsString;
end;

procedure TForm2.tl1FocusedNodeChanged(Sender: TcxCustomTreeList;
  APrevFocusedNode, AFocusedNode: TcxTreeListNode);
begin
  dm.q_zrl.Close;
  q_nar.Close;
  q_nar_z.Close;
  if AFocusedNode = nil then
    exit;
  dm.q_zrl.Params.ParamByName('atab').AsString :=
    copy(AFocusedNode.Values[1], 7);
  dm.q_zrl.Params.ParamByName('agodmesr').AsString :=
    copy(AFocusedNode.Values[1], 1, 6);

  q_nar.ParamByName('aym').AsString := copy(AFocusedNode.Values[1], 1, 6);
  q_nar_z.ParamByName('aym').AsString := copy(AFocusedNode.Values[1], 1, 6);

  dm.q_zrl.Open;
  q_nar.Open;
  q_nar_z.Open;
  // label1.Caption:=copy(tl1.FocusedNode.Values[1],1,6);

  // if node=nil then exit;
  { dm.DataModule1.ym_nod.RecNo:=longint(node.Data);
    dm.DataModule1.zrl_q.Close;
    dm.DataModule1.zrl_q.open; }
end;

procedure TForm2.TV1Change(Sender: TObject; Node: TTreeNode);
begin
  if Node = nil then
    exit;
  dm.q_ym_nod.RecNo := longint(Node.Data);
  // dm.zrl_q.Close;
  // dm.zrl_q.open;

end;

end.
